package opertation;

import book.Book;
import book.BookList;

import java.util.Scanner;

/**
 * 归还图书
 */
public class ReturnOpertation implements IOPertation{
    @Override
    public void work(BookList bookList) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入要归还的书名");
        String name = scanner.nextLine();
        int sizeof = bookList.getBooksSizeof();
        for(int i = 0 ;i < sizeof;i++) {
            Book book = bookList.getBook(i);
            if(book.getName().equals(name)) {
                if(book.isOpration() == false) {
                    System.out.println("归还失败 图书未被借出 ！！！");
                    return ;
                }else {
                    book.setOpration(false);
                    System.out.println("归还成功 ！！！");
                    return ;
                }
            }
        }
        System.out.println("归还失败 没有该图书 ！！！");
    }
    }
